/*
* File: unitialized_fill.cpp
* 测试用例修改自泛型编程和stl 侯捷译 10.4 内存管理基本元素
*/
#include "Allocator.h"
#include <iostream>
#include <algorithm>
class Int {
public:
	Int (int x) : val(x) { std::cout << "Int(" << val << ")" << std::endl;}
	~Int() { val = 0; std::cout << "~Int()" << std::endl;}
	int get() const { return val; }
	
private:
	int val;
};

void display(const Int & x)
{
	std::cout << x.get() << std::endl;
}

int main()
{
	const int N = 137;
	Int val(46);

	Int * A = (Int *) malloc(N * sizeof(Int));
	Allocator<Int> test;
	test.uninitialized_fill(A, A + N, val);
	std::for_each(A, A + N, display);
}
